*TITLE: HOW DO VOTERS HOLD POLITICIANS ACCOUNTABLE FOR PERSONAL WELFARE? EVIDENCE OF A SELF-SERVING BIAS
*JOURNAL: JOURNAL OF POLITICS
*AUTHOR: MARTIN VINÆS LARSEN
*FILE: STUDY 3 ANALYSES (FIGURE 4, 5 & APPENDIX TABLES & FIGURES)
*DEPENDENCIES: eststo, blindschemes


///EXPERIMENT 1+2///

*importing exp1 data
use "exp1.dta", clear

*guide for understanding variables
*hus=house
*arb=employment
*_socio=national
*_ego=personal
*_base=control
*_s=positive
*_f=negative

*recodes for exp1 (both dvs and treatment vars)
gen manip_hus="."
gen hus=0
foreach x in hus_ego_s hus_ego_f hus_ego_base hus_socio_s hus_socio_f hus_socio_base {
replace `x'="." if `x'==""
replace `x'="0" if `x'=="Slet ikke0"
replace `x'="10" if substr(`x',1,1)=="I"
destring `x', replace
replace hus=`x' if `x'!=.
replace manip_hus="`x'" if `x'!=.
}
encode manip_hus, gen(manhus)

gen manip_arb="."
gen arb=0
foreach x in arb_socio_s arb_socio_f arb_socio_base arb_ego_f arb_ego_s arb_ego_base {
replace `x'="." if `x'==""
replace `x'="0" if `x'=="Slet ikke0"
replace `x'="10" if substr(`x',1,1)=="I"
destring `x', replace
replace arb=`x' if `x'!=.
replace manip_arb="`x'" if `x'!=.
}
encode manip_arb, gen(manarb)


*saving study 1 in tempfile
drop manip* arb_* hus_*
gen study=1
tempfile study1
save `study1'

*importing experiment 2 data
use "exp2.dta", clear

*recodes for exp 2

*dvs
gen hus= Q03_1a-1
replace hus=Q03_1b-1 if hus==.
gen arb= Q03_2a-1
replace arb=Q03_2b-1 if arb==.

*treatment
recode Split_Q03_1a (1=3) (3=1)
recode Split_Q03_2a (1=2) (2=3) (3=1) 
recode Split_Q03_1b (1=3) (3=1)
recode Split_Q03_2b (1=3) (3=1)
gen manhus=Split_Q03_1a if Split_exp1_s1==1
replace manhus=3+Split_Q03_1b if Split_exp1_s1==2
gen manarb=Split_Q03_2a if Split_exp1_s2==1
replace manarb=3+Split_Q03_2b if Split_exp1_s2==2
*coding control=1, positive=2, negative=3 for own economy and control=4, positive=5, negative=6 for national economy. 

keep manarb manhus arb hus
gen study=2

*merging experiments one and 2
append using `study1'

*rescaling dv
replace hus=hus/10
replace arb=arb/10

*running models for experiments seperately and pooled
tempfile a1 a2 a3 a4 a5 a6
eststo a: reg arb i.manarb if study==1, r
margins manarb, saving(`a1')
eststo b: reg arb i.manarb if study==2, r
margins manarb, saving(`a2')
eststo c: reg arb i.manarb i.study, r
margins manarb, saving(`a6')
eststo d: reg hus i.manhus if study==1, r
margins manhus, saving(`a3')
eststo e: reg hus i.manhus if study==2, r
margins manhus, saving(`a4')
eststo f: reg hus i.manhus i.study, r
margins manhus, saving(`a5')

*regression tables for appendix

*table for housing outcome
esttab d e f using "apdxfullhouse.tex", replace nonum drop(1.manhus 1.study) ///
 star(+ 0.10 * 0.05) b(%9.2fc) label mtitles("Exp. 1"  "Exp. 2"  "Pooled" ) ///
stats(rmse r2 N, label(" $\sigma$" "R$^2$" "Observations") fmt(%9.2f %9.2f %9.0fc) )  ///
varlabel(_cons "Constant" 2.manhus "Worse - Own" 3.manhus "Better - Own" ///
4.manhus "Same - National" 5.manhus "Worse - National" 6.manhus "Better - National" 2.study "Exp. 2" ) ///
se  title(Experiments 1 and 2; how responsible is the government for housing?} \footnotesize \label{table:apdxfullhouse)

*table for employment outcome
esttab a b c using "apdxfullarb.tex", replace drop(1.manarb 1.study) ///
 star(+ 0.10 * 0.05) b(%9.2fc) label mtitles("Exp. 1"  "Exp. 2"  "Pooled" ) ///
stats(rmse r2 N, label(" $\sigma$" "R$^2$" "Observations") fmt(%9.2f %9.2f %9.0fc) )  ///
varlabel(_cons "Constant" 2.manarb "Worse - Own" 3.manarb "Better - Own" ///
4.manarb "Same - National" 5.manarb "Worse - National" 6.manarb "Better - National" 2.study "Exp. 2 ") nonum ///
se  title(Experiments 1 and 2; how responsible is the government for employment?} \footnotesize \label{table:apdxfullarb)


*descriptive statistics for appendix
replace study=study-1
la var hus "Responsibility housing"
la var arb "Responsibility employment"
la var study "Exp. 2"
file open anyname using "desexp12.txt", write text replace 
file write anyname  _newline  _col(0)  "\begin{table} [htbp] \centering \caption{Descriptive statistics, Experiment 1--2 \label{desexp12}} \footnotesize \begin{tabular}{l*{6}{c}}\hline\hline "
file write anyname _newline _col(0) "&Mean & SD & Min & Median & Max & n\\ \hline"
foreach x of var  hus arb study  {
su  `x' , d
file write anyname  _newline  _col(0) (`"`: var label `x''"') "&" _col(25) %9.2f  (r(mean)) " &" _col(45) %9.2f  (r(sd)) " &" _col(65) %9.2f  (r(min)) " &"   _col(85) %9.2f  (r(p50)) " &" _col(105) %9.2f  (r(max)) " &" _col(125) %9.0f  (r(N)) " \\"
}
file write anyname _newline _col(0) "\hline\hline"
file write anyname _newline _col(0) "\end{tabular}"
file write anyname _newline _col(0) "\end{table}"
file close anyname

*figure 3
use `a1', clear
gen study=1
append using `a2'
replace study=2 if study==.
gen var=1
append using `a3'
replace study=1 if study==.
append using `a4'
replace var=2 if var==.
replace study=2 if study==.
append using `a5'
replace var=2 if var==.
append using `a6'
replace var=1 if var==.
replace study=3 if study==.

gen ub90=_margin+_se*1.64
gen ub95=_margin+_se*1.96
gen lb90=_margin-_se*1.64
gen lb95=_margin-_se*1.96
gen soc=1 if _m1 >3
replace _m1=_m1-3 if soc==1
recode _m1 (2=1) (1=2)
replace _m1=. if _m1==2 |_m1==5
replace _m1=_m1+0.1 if study==2
replace _m1=_m1-0.1 if study==1
preserve
keep if var==2 & soc==.
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative"  3 "Positive", labsize(large) nogrid) ///
scheme(plotplain)  ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Housing", size(vlarge)) ylab(0.2(0.1)0.6, labsize(large)) name(a, replace) legend(off)
restore
preserve
keep if var==1 & soc==.
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative" 3 "Positive", labsize(large) nogrid) ///
scheme(plotplain) legend(order(5 7 6) ring(0) pos(1) label(6 "Original") label(7 "Replication") label(5 "Pooled") ) ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Employment", size(vlarge)) ylab(0.2(0.1)0.6, labsize(large)) name(b, replace)
restore
graph combine a b, scheme(plotplain) title(Personal Outcomes, pos(11) size(large))   xsize(5)

graph export expdataemploy.pdf, replace

preserve
keep if var==2 & soc==1
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative"  3 "Positive", labsize(large) nogrid) ///
scheme(plotplain)  ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Housing", size(vlarge)) ylab(0.4(0.1)0.8, labsize(large)) name(a, replace) legend(off)
restore
preserve
keep if var==1 & soc==1
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative" 3 "Positive", labsize(large) nogrid) ///
scheme(plotplain) legend(order(5 7 6) ring(0) pos(1) label(6 "Original") label(7 "Replication") label(5 "Pooled") ) ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Employment", size(vlarge)) ylab(0.4(0.1)0.8, labsize(large)) name(b, replace)
restore
graph combine a b, scheme(plotplain) title(National Outcomes, pos(11) size(large))   xsize(5)
graph export expdatahousing.pdf, replace


*extra graph including neutral category for appendix
replace _m1=2 if _m1==.
replace _m1=_m1+0.1 if study==2 & _m1==2
replace _m1=_m1-0.1 if study==1 & _m1==2

preserve
keep if var==2 & soc==.
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative"  3 "Positive", labsize(large) nogrid) ///
scheme(plotplain)  ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Housing", size(vlarge)) ylab(0.2(0.1)0.6, labsize(large)) name(a, replace) legend(off)
restore
preserve
keep if var==1 & soc==.
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative" 3 "Positive", labsize(large) nogrid) ///
scheme(plotplain) legend(order(5 7 6) ring(0) pos(1) label(6 "Original") label(7 "Replication") label(5 "Pooled") ) ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Employment", size(vlarge)) ylab(0.2(0.1)0.6, labsize(large)) name(b, replace)
restore
graph combine a b, scheme(plotplain) title(Personal Outcomes, pos(11) size(large))   xsize(5)

graph export neutexpdataemploy.pdf, replace

preserve
keep if var==2 & soc==1
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative"  3 "Positive", labsize(large) nogrid) ///
scheme(plotplain)  ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Housing", size(vlarge)) ylab(0.4(0.1)0.8, labsize(large)) name(a, replace) legend(off)
restore
preserve
keep if var==1 & soc==1
sort _m1 study
twoway rspike ub90 lb90 _m1 if study==3  , lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1 if study==3, lwidth(medthick) lcolor(black%50) || ///
rspike ub90 lb90 _m1 if study<3, lwidth(medthick) lcolor(black%50) || ///
rspike ub95 lb95 _m1 if study<3, lcolor(black%50) || ///
scatter _margin _m1 if study==3, msym(O) msize(vlarge) mcolor(black%50) || ///
scatter _margin _m1 if study==1, msym(O)  mfcolor(white) mlcolor(black%50) mlwidth(medthick) xoverhangs ///
|| scatter _margin _m1 if study==2, msym(D) mfcolor(white) mlcolor(black%50) mlwidth(medthick) xlabel(1 "Negative" 3 "Positive", labsize(large) nogrid) ///
scheme(plotplain) legend(order(5 7 6) ring(0) pos(1) label(6 "Original") label(7 "Replication") label(5 "Pooled") ) ytitle(How Responsible is the Government?, size(medlarge)) ///
xtitle(" " "Employment", size(vlarge)) ylab(0.4(0.1)0.8, labsize(large)) name(b, replace)
restore
graph combine a b, scheme(plotplain) title(National Outcomes, pos(11) size(large))   xsize(5)

graph export neutexpdatahousing.pdf, replace



///Experiment 3///

use "exp3.dta", clear

*recoding dvs
gen huspers=(Q10_a-1)/9 if split_sample2==1
replace huspers=(Q10_b-1)/9 if split_sample2==2
gen husgov=(Q10_c-1)/9 if split_sample2==3
replace husgov=(Q10_d-1)/9 if split_sample2==4
*huspers: how responsible are you for your own house inc/dec in value?
*husgov: how responsible is the gov for some house inc/dec in value?

*treatment
gen neg=0
replace neg=1 if split_sample2==2 |split_sample2==3 //coding negative outcome as 1, positive as 0
drop Q10*

*running models
tempfile b1 b2
eststo a: reg huspers i.neg, r
margins neg, saving(`b1')
eststo b: reg husgov i.neg, r
margins neg, saving(`b2')

*table for appendix
esttab a b using "apdxfullexp3.tex", nonum replace drop(0.neg) ///
 star(+ 0.10 * 0.05) b(%9.2fc) label mtitles("Voters themselves" "Government") ///
stats(rmse r2 N, label(" $\sigma$" "R$^2$" "Observations") fmt(%9.2f %9.2f %9.0fc) )  ///
varlabel(_cons "Constant" 1.neg "Negative change (ref: positive)" ) ///
se  title(Experiment 3 - how responsible is...?} \footnotesize \label{table:exp3)


*descriptive statistics (for appendix)
la var huspers "Personal responsibility"
la var husgov "Government responsibility"
file open anyname using "desexp3.txt", write text replace 
file write anyname  _newline  _col(0)  "\begin{table} [htbp] \centering \caption{Descriptive statistics, Experiment 3 \label{desexp3}} \footnotesize \begin{tabular}{l*{6}{c}}\hline\hline "
file write anyname _newline _col(0) "&Mean & SD & Min & Median & Max & n\\ \hline"
foreach x of var  hus*  {
su  `x' , d
file write anyname  _newline  _col(0) (`"`: var label `x''"') "&" _col(25) %9.2f  (r(mean)) " &" _col(45) %9.2f  (r(sd)) " &" _col(65) %9.2f  (r(min)) " &"   _col(85) %9.2f  (r(p50)) " &" _col(105) %9.2f  (r(max)) " &" _col(125) %9.0f  (r(N)) " \\"
}
file write anyname _newline _col(0) "\hline\hline"
file write anyname _newline _col(0) "\end{tabular}"
file write anyname _newline _col(0) "\end{table}"
file close anyname



*figure 5
use `b1', clear
gen pers=1
append using `a5'
drop if _m1 >3
replace pers=0 if pers==.
replace _m1=. if _m1==2 & pers==0
replace _m1=2 if _m1==3
replace _m1=_m1-1 if pers==0
recode _m1 (0=1) (1=0) if pers==1

gen ub90=_margin+_se*1.64
gen ub95=_margin+_se*1.96
gen lb90=_margin-_se*1.64
gen lb95=_margin-_se*1.96

twoway rspike ub90 lb90 _m1, lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1, lwidth(medthick) lcolor(black%50) || ///
scatter _margin _m1 if pers==0, msym(O) mfcolor(black%50) msize(vlarge) xoverhangs || ///
scatter _margin _m1 if pers==1, msym(O) msize(vlarge)  ///
mfcolor(white) mlcolor(black%50)  mlwidth(medthick) xlabel(0 "Negative" 1 "Positive", labsize(large) nogrid) ///
scheme(plotplain) ytitle(How Responsible is...?, size(medlarge)) ///
ylab(0.2(0.1)0.6, labsize(large)) name(a1, replace) xtitle(" " "Housing", size(large)) ///
legend(order(3 4) ring(0) pos(1) label(3 "Government") label(4 "My Self")) 

use `b2', clear
gen pers=1
append using `a5'
drop if _m1 >3
replace pers=0 if pers==.
replace _m1=. if _m1==2 & pers==0
replace _m1=2 if _m1==3
replace _m1=_m1-1 if pers==0
recode _m1 (0=1) (1=0) if pers==1
gen ub90=_margin+_se*1.64
gen ub95=_margin+_se*1.96
gen lb90=_margin-_se*1.64
gen lb95=_margin-_se*1.96
twoway rspike ub90 lb90 _m1, lwidth(thick) lcolor(black%50)  || ///
rspike ub95 lb95 _m1, lwidth(medthick) lcolor(black%50) || ///
scatter _margin _m1 if pers==0, msym(O) mfcolor(black%50) msize(vlarge) xoverhangs || ///
scatter _margin _m1 if pers==1, msym(O) msize(vlarge)  ///
mfcolor(white) mlcolor(black%50)  mlwidth(medthick) xlabel(0 "Negative" 1 "Positive", labsize(large) nogrid) ///
scheme(plotplain) ytitle(How Responsible is the government?, size(medlarge)) ///
ylab(0.2(0.1)0.6, labsize(large)) name(b1, replace) xtitle(" " "Housing", size(large)) ///
legend(order(3 4) ring(0) pos(1) label(3 "My House") label(4 "A House")) 

*combining graph
graph combine b1 a1, scheme(plotplain)   xsize(5)
graph export mechanism.pdf, replace


********************************************************************************
